#pragma once
#include "Dllexport.h"
#include <functional>
#include <map>
#include <vector>
#include "Handler.h"

namespace NBGUI
{

class ElementNode;

class GUIAPI FunctionCaller
{
public:

	typedef std::function< void( ElementNode*, std::vector<info>&, std::string& funcName ) > FunctionType;

	void call( ElementNode* pObject, const char* functionName, std::vector<info>& para, std::string& fName )
	{
		// Find the function.
		auto function = m_functions[ functionName ];	// TODO

		// If I have it, call it.
		//
		auto boundFunction = std::bind( function, pObject, para, fName);
		boundFunction();
	}

	void registerFunction( const char* functionName, const FunctionType& function )
	{
		m_functions[ functionName ] = function;
	}

private:
	std::map< std::string, FunctionType > m_functions;
};

}